package com.prezs.Javaio;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;

public class BufferedStream {
	
	public static void readOneLine() throws IOException {
		// 创建字符缓冲流对象--读取
		BufferedReader br =  new BufferedReader(new FileReader("input.txt"));
		// 存取读取的内容
		String line = null;
		// 循环读取 readLine()方法读到最后会返回null
		while((line = br.readLine()) != null) {
			System.out.println(line);
			System.out.println("------");
		}
		br.close();
	} 
	
	public static void linefeed() throws IOException {
		// 创建字符缓冲流对象--写入
		BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));
		bw.write("你好，");
		bw.newLine();
		bw.write("Java I/O");
		bw.newLine();
		bw.flush();
		bw.close();
		
	}
	private static char[] values = {'1', '2', '3'};
	private static int hash;
	private static String str = "abc";
	public static int testHashCode() {
		int h = 0;
		if (h == 0 && values.length > 0) {
			char val[] = values;
			
			for(int i = 0;i<values.length;i++) {
				h = 31 * h + val[i];
				System.out.println(h);
			}
			hash = h;
			System.out.println(h);
		}
		return h;
	}
	public static void main(String[] args) throws IOException {
		readOneLine();
		
		linefeed();
		
		testHashCode();
	}
}
